package com.ecoolex.discount.sales.pojo;

import java.util.List;

import lombok.Data;

@Data
public class CtripYWResponse<T> {
	private String errno;

	private String errmsg;

	private String sign;

	private List<T> data;

	public static final String SUCCESS = "00";

	public static final String UNKNOW = "01";

	public static final String SYSTEM = "02";

	public static final String PARAM = "03";

	public static final String TOKEN = "04";

	public static final String SIGN = "05";

	private CtripYWResponse() {
	}

	/**
	 * 成功
	 * @return
	 */
	public static CtripYWResponse ok() {
		CtripYWResponse ctripYWResponse = errno(SUCCESS);
		ctripYWResponse.setErrmsg("成功");
		return ctripYWResponse;
	}

	/**
	 * 未知错误
	 * @return
	 */
	public static CtripYWResponse unknow() {
		CtripYWResponse ctripYWResponse = errno(UNKNOW);
		ctripYWResponse.setErrmsg("未知错误");
		return ctripYWResponse;
	}

	/**
	 * 系统错误
	 * @return
	 */
	public static CtripYWResponse system() {
		CtripYWResponse ctripYWResponse = errno(SYSTEM);
		ctripYWResponse.setErrmsg("系统错误");
		return ctripYWResponse;
	}

	/**
	 * 参数值错误
	 * @return
	 */
	public static CtripYWResponse param() {
		CtripYWResponse ctripYWResponse = errno(PARAM);
		ctripYWResponse.setErrmsg("参数值错误");
		return ctripYWResponse;
	}

	/**
	 * token失效
	 * @return
	 */
	public static CtripYWResponse token() {
		CtripYWResponse ctripYWResponse = errno(TOKEN);
		ctripYWResponse.setErrmsg("token失效");
		return ctripYWResponse;
	}

	/**
	 * 签名错误
	 * @return
	 */
	public static CtripYWResponse sign() {
		CtripYWResponse ctripYWResponse = errno(SIGN);
		ctripYWResponse.setErrmsg("签名错误");
		return ctripYWResponse;
	}

	public static CtripYWResponse errno(String errno) {
		CtripYWResponse ctripYWResponse = new CtripYWResponse();
		ctripYWResponse.setErrno(errno);
		return ctripYWResponse;
	}

	public CtripYWResponse errmsg(String errmsg) {
		this.errmsg = errmsg;
		return this;
	}

	public CtripYWResponse sign(String sign) {
		this.sign = sign;
		return this;
	}

	public CtripYWResponse data(List<T> data) {
		this.data = data;
		return this;
	}

}
